<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>登录</title>
		<link rel="stylesheet" href="../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../css/login.css" />
		<link rel="stylesheet" href="../layui/lay/modules/layer.js">
		<link rel="stylesheet" href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css">
	</head>

	<body class="beg-login-bg">
		<div class="beg-login-box">
			<header>
				<h1>后台登录</h1>
			</header>
			<div class="beg-login-main">
				<div class="layui-form" method="post">
					<!-- <input name="__RequestVerificationToken" type="hidden" value="fkfh8D89BFqTdrE2iiSdG_L781RSRtdWOH411poVUWhxzA5MzI8es07g6KPYQh9Log-xf84pIR2RIAEkOokZL3Ee3UKmX0Jc8bW8jOdhqo81" /> -->
					<div class="layui-form-item">
						<label class="beg-login-icon">
						<i class="fa fa-user-o" aria-hidden="true"></i>
					</label>
						<input type="text" id="userName" lay-verify="userName" autocomplete="off" placeholder="这里输入登录名" class="layui-input">
					</div>
					<div class="layui-form-item">
						<label class="beg-login-icon">
						<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
					</label>
						<input type="password" id="password" lay-verify="password" autocomplete="off" placeholder="这里输入密码" class="layui-input">
					</div>
					<div class="layui-form-item">
						<div class="beg-pull-left beg-login-remember">
							<label>记住帐号？</label>
							<input type="checkbox" name="rememberMe" value="true" lay-skin="switch" checked title="记住帐号">
						</div>
						<div class="beg-pull-right">
							<button class="layui-btn layui-btn-primary" lay-submit lay-filter="login" id="login">
						<i class="fa fa-smile-o" aria-hidden="true"></i> 登录
						</button>
						</div>
						<div class="beg-clear"></div>
					</div>
				</div>
			</div>
			<footer>
				<p>Beginner © www.zhengjinfan.cn</p>
			</footer>
		</div>
		<script type="text/javascript" src="../layui/layui.js"></script>
		<script type="text/javascript" src="../js/jquery-1.12.3.min.js"></script>
		<script type="text/javascript" src="../js/index.js"></script>
		<script type="text/javascript" src="../js/jquery.cookie.js"></script>
		<script>
			var data = {
				"code": 200,
				"admin": {
					"adminId": 100124,
					"adminSex": "女",
					"adminName": "hwjlmn",
					"adminPower": 92252,
					"adminUrl": "../../images/6.jpg",
					"adminNickname": "hwjlmn"
				}
			}
			/*layui.use(['layer', 'form'], function() {

				var layer = layui.layer,
					$ = layui.jquery,
					form = layui.form();
				//alert($.cookie("adminNickname"))

				function varify(data) {
					if (data.code == 200) {
						$.cookie("adminNickname", data.admin.adminNickname, {
							path: '/'
						});
						$.cookie("adminUrl", data.admin.adminUrl, {
							path: '/'
						});
						$.cookie("adminId", data.admin.adminId, {
							path: '/'
						});
						window.location.href = "statisticalReport/datareport.html"
							// window.location.href = "statisticalReport/datareport.html?name=" + data.admin.adminName + "&&headimg="+data.admin.adminUrl+"";
							// window.location.href = "/Account/B?id="+data.id+""; 
					} else {
						alert("用户名密码错误");
					}
				}

				form.on('submit(login)', function() {
					/*$.ajax({
								type: "post",
								url: "/randomdelivery/AdminController/admin/login",
								data: JSON.stringify({
									"adminName": adminName,
									"adminPwd": adminPwd
								}),
								async: true,
								dateType: "json",
								contentType: "application/json",
								success: function(data) {
								},
								Error: function() {
									alert("服务器出错");
								}
							})
					varify(data);

				});
			});*/
			$(document).ready(function()
			{
				if($.cookie("adminName")!=null)
				{
					$("#userName").val($.cookie("adminName"));
				}
				if($.cookie("adminPwd")!=null)
				{
					$("#password").val($.cookie("adminPwd"));
				}
			})

			$("#login").click(function() {
				$.ajax({
					type: "post",
					url: "/randomdelivery/AdminController/admin/login",
					data: JSON.stringify({
						"adminName": $("#userName").val(),
						"adminPwd": $("#password").val()
					}),
					async: true,
					dateType: "json",
					contentType: "application/json",
					success: function(data) {
						if(data.code == 200) {
							$.cookie("adminName",$("#userName").val());
							$.cookie("adminPwd",$("#password").val());
							
							window.location.href = "statisticalReport/datareport.html?name=" + data.admin.adminName + "&&headimg=" + 								data.admin.adminUrl + "";
						}
						else
						{
							alert("用户名或密码错误")
						}
					},
					Error: function() {
						alert("服务器出错");
					}
				})
			})
		</script>
	</body>

</html>